import numpy as np

nd1 = np.random.randint(1, 100, size=(6, 50, 3))
# print(nd1)
nd2 = nd1.cumsum(axis=2)
# print(nd2)
nd3 = nd2[::1, ::1, 2:]
score = nd3.reshape(300, 1)
sex = np.random.randint(0, 2, (300, 1)) / 2 == 0
print("score: %s " % score)

nd4 = np.append(sex, score, axis=1)
nd5 = nd1.reshape(300, 3)
nd6 = np.append(sex, nd5, axis=1)
print("data: %s " % nd6)
courseNames = ["python", "math", "Chinese"]
sexName = ["男", "女"]


def get_result(nd, index, sex_condition, sex_name):
    course_name = courseNames[index]
    data = nd[::1, index + 1:index + 2][sex_condition]
    print(" {0} {1} 最低分： {2}".format(sex_name, course_name, np.min(data)))
    print(" {0} {1} 最高分： {2}".format(sex_name, course_name, np.max(data)))
    print(" {0} {1} 平均分： {2}".format(sex_name, course_name, np.mean(data)))
    print(" {0} {1} 中位数： {2}".format(sex_name, course_name, np.median(data)))
    print(" {0} {1} 标准差： {2}".format(sex_name, course_name, np.std(data)))


flag = True
for name in sexName:
    for j in range(0, 3):
        get_result(nd6, j, sex == flag, name)
        flag = not flag

# pythonScore = nd6[::1, 1:2]
# mathScore = nd6[::1, 2:3]
# chineseScore = nd6[::1, 3:4]
# phyMin = np.min(pythonScore[sex])
# print("男 python 最低分：%d" % phyMin)
#
# phyMax = np.max(pythonScore[sex])
# print("男 python 最高分：%d" % phyMax)
#
# phyMean = np.mean(pythonScore[sex])
# print("男 python 平均分：%d" % phyMean)
#
# phyMedian = np.median(pythonScore[sex])
# print("男 python 中位数：%d" % phyMedian)
#
# sex = (sex == False)
# phyMin = np.min(pythonScore[sex])
# print("女 python 最低分：%d" % phyMin)
#
# phyMax = np.max(pythonScore[sex])
# print("女 python 最高分：%d" % phyMax)
#
# phyMean = np.mean(pythonScore[sex])
# print("女 python 平均分：%d" % phyMean)
# for d in nd1:
#     for row in d:
#         nd2.pu = sum(row)
#         print("row is %s" % sum(row))
#         # print(np.cumsum(d))
